package com.hdoit.ares.logical.acc.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.hdoit.ares.logical.acc.dao.IGoldenBeanInfoDao;
import com.hdoit.ares.logical.acc.model.GoldenBeanInfo;
import com.hdoit.ares.logical.acc.service.IGoldenBeanInfoService;
import com.hdoit.ares.logical.cust.model.Customer;
import com.hdoit.ares.logical.viewmodel.acc.GoldenBeanInfoSearch;
import com.tennetcn.common.dao.base.impl.SuperService;
import com.tennetcn.common.enums.ModelStatus;
import com.tennetcn.common.message.PagerModel;
import com.tennetcn.common.utils.CommonUtils;
/**
 * @author      caochengmeng
 * @email       
 * @createtime  2017年12月05日 11:35:07
 * @comment
 */
@Component
public class GoldenBeanInfoServiceImpl extends SuperService<GoldenBeanInfo> implements IGoldenBeanInfoService{
	
	private IGoldenBeanInfoDao goldenBeanInfoDao;

	public IGoldenBeanInfoDao getGoldenBeanInfoDao() {
		return goldenBeanInfoDao;
	}
	@Resource
	public void setGoldenBeanInfoDao(IGoldenBeanInfoDao goldenBeanInfoDao) {
		this.goldenBeanInfoDao = goldenBeanInfoDao;
	}
	private IGoldenBeanInfoService goldenBeanInfoService;
	
	public IGoldenBeanInfoService getGoldenBeanInfoService() {
		return goldenBeanInfoService;
	}
	@Resource
	public void setGoldenBeanInfoService(IGoldenBeanInfoService goldenBeanInfoService) {
		this.goldenBeanInfoService = goldenBeanInfoService;
	}
	@Override
	public GoldenBeanInfo queryModel(String id){
		return goldenBeanInfoDao.queryModel(id);
	}
	@Override
	public List<GoldenBeanInfo> queryList(GoldenBeanInfoSearch goldenBeanInfoSearch, PagerModel pagerModel) {	
		return goldenBeanInfoDao.queryList(goldenBeanInfoSearch, pagerModel);
	}
	
	@Override
	public boolean addGoldenBeanInfo(Customer customer){
		GoldenBeanInfo goldenBeanInfo = new GoldenBeanInfo();
		goldenBeanInfo.setId(CommonUtils.getKeyId());
		goldenBeanInfo.setCustomerId(customer.getId());
		goldenBeanInfo.setAccount(customer.getUserIdentity());
		goldenBeanInfo.setName(customer.getUsername());
		goldenBeanInfo.setServiceAward(0);
		goldenBeanInfo.setHatcheryAward(0);
		goldenBeanInfo.setPromotionAward(0);
		goldenBeanInfo.setFirstSharingAward(0);
		goldenBeanInfo.setSecondSharingAward(0);
		goldenBeanInfo.setModelStatus(ModelStatus.add);		
		return applyChange(goldenBeanInfo);
	}
	@Override
	public GoldenBeanInfo queryModelByCustomerId(String customerId) {
		return goldenBeanInfoDao.queryModelByCustomerId(customerId);
	}
	@Override
	public List<GoldenBeanInfo> queryAllList(GoldenBeanInfoSearch search, PagerModel pagerModel) {
		
		return goldenBeanInfoDao.queryAllList(search, pagerModel);
	}
	@Override
	public int queryAllCount(GoldenBeanInfoSearch search) {
		
		return goldenBeanInfoDao.queryAllCount(search);
	}
	@Override
	public GoldenBeanInfo queryThisModel(String id) {
		
		return goldenBeanInfoDao.queryThisModel(id);
	}
}